import * as actionTypes from './actionTypes'
import { fromJS } from 'immutable'

const defaultState = fromJS({
    focused: false,
    mouseIn: false,
    list: [],
    page: 1,
    totalPage: 1
})

export default (state = defaultState, action)=>{
    switch (action.type) {
        case actionTypes.SEARCH_FOCUS:
            return state.set("focused",true)
        case actionTypes.SEARCH_BLUR:
            return state.set("focused",false)
        case actionTypes.SEARCH_Mouse_Enter:
            return state.set("mouseIn",true)
        case actionTypes.SEARCH_Mouse_Leave:
            return state.set("mouseIn",false)
        case actionTypes.GET_SEARCH_HOTWORD:
            return state.merge({
                "list": action.data,
                "totalPage": action.totalPage
            })
        case actionTypes.SWITCH_SEARCH_WORD:
            return state.set("page",action.page)
        default:
            return state
    }
}